package com.chart.demo.httpservice;

import java.io.IOException;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;

import com.chart.demo.db.DbFactory;

public class TimerService extends HttpServlet implements ServletContextListener {

	private static final String CONTENT_TYPE = "text/xml; charset=utf-8";
	
	public void service(ServletRequest request, ServletResponse response)
			throws ServletException, IOException {

	}
	public void contextInitialized(ServletContextEvent sce) {
		ServletContext sc = sce.getServletContext();
		
		DbFactory.ip = sc.getInitParameter("Address");
		DbFactory.port = sc.getInitParameter("Port");
		DbFactory.username = sc.getInitParameter("Username");
		DbFactory.password = sc.getInitParameter("Password");
		
		DbFactory.streetIp = sc.getInitParameter("StreetAddress");
		DbFactory.streetPort = sc.getInitParameter("StreetPort");
		DbFactory.streetUsername = sc.getInitParameter("StreetUsername");
		DbFactory.streetPassword = sc.getInitParameter("StreetPassword");
		
		System.out.println("Username="+DbFactory.username);
		System.out.println("Password="+DbFactory.password);
		System.out.println("Address="+DbFactory.ip);
		System.out.println("StreetUsername="+DbFactory.streetUsername);
		System.out.println("StreetPassword="+DbFactory.streetPassword);
		System.out.println("StreetAddress="+DbFactory.streetIp);
		System.out.println("The demo service is starting...");
	}

	public void contextDestroyed(ServletContextEvent sce) {

		System.out.println("The demo service is closing...");

	}

}
